package switcher;

import java.awt.Image;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

import common.TVConsts;

public class ImageSwitcher extends AbsSwitcher {
	Image img = null;
	File imgFile = null;
	ByteArrayInputStream byteStream = null;

	public ImageSwitcher() {
		super(TVConsts.SERVER_NAME, TVConsts.CH1_PORT, TVConsts.MC_CH1_ADDRESS,
				TVConsts.MC_PORT);
	}

	public ImageSwitcher(String serverName, int port, String mcAddress,
			int mcPort) {
		super(serverName, port, mcAddress, mcPort);
	}

	public Image getImage() {
		return img;
	}

	@Override
	public void msgInterrupt(byte[] data) {
		byteStream = new ByteArrayInputStream(data);
//		System.out.println("switcher : " + data.length);
		try {
			img = ImageIO.read(byteStream);
			// System.out.println(img);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
